<?php

/**
 * ctrlLogin  Control d'entrada
 * 
 * Projecte IntraMail
 * @version 1.0
 * @author Jordi & Manel 11/04/2012
 * @copyright Creative commons (by-nc-nd) Reconeixement - NoComercial - CompartirIgual 
 */
require_once '../models/ctrlLogin.class.php';
$ctrlLogin = new CtrlLogin();

if (isset($_POST['entrar']) && $_POST['entrar'] == 'entrar') {
    if ($ctrlLogin->registra($_POST['nick'], $_POST['pass'])) {
        $usuari = $ctrlLogin->getNick();
        $dni = $ctrlLogin->getDni();
        $rols = $ctrlLogin->getRols();
        //include('../views/formLogout.php');
        echo "<script>getData('menu.php,'menu');</script>";
    } else {
        include('../views/formLogin.php');
        echo "<script>alert('Usuari i/o password incorrecte');</script>";
    }
} elseif (isset($_POST['sortir'])) {
    $ctrlLogin->logout();
    include('../views/formLogin.php');
    echo "<script>getData('menu.php,'menu');</script>";
}
?>